﻿using Microsoft.AspNetCore.Mvc;

namespace PageOffice6_Net_Core.Controllers
{
    public class DataRegionFillController : Controller
    {

        public IActionResult Word()
        {
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);

            PageOfficeNetCore.Word.WordDocumentWriter doc = new PageOfficeNetCore.Word.WordDocumentWriter();
            //打开数据区域
            PageOfficeNetCore.Word.DataRegionWriter dataRegion1 = doc.OpenDataRegion("PO_userName");
            dataRegion1.Value = "张三";

            PageOfficeNetCore.Word.DataRegionWriter dataRegion2 = doc.OpenDataRegion("PO_deptName");
            dataRegion2.Value = "销售部";

            poCtrl.SetWriter(doc);
            //打开Word文档
            poCtrl.WebOpen("doc/test.doc", PageOfficeNetCore.OpenModeType.docNormalEdit, "tom");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View();
        }

    }
}